define(["dojo/_base/declare", "dijit/form/Form", "dijit/form/TextBox", "dijit/form/Button"], function(declare){
    declare("my.form.EditAnotherUserForm", [dijit.form.Form], {
    	startup : function(){
    		var userDropDown = dijit.byId("anotherUserDropDown");
    		dojo.connect(userDropDown, "onChange", this, function(){
    			dojo.xhrPost(
    				    {
    				        url : "getUserAction.action?user.id=" + dijit.byId("anotherUserDropDown").get('value'),
    				        handleAs : "json",
    				        load : dojo.hitch(this, this.onLoadUser),
    				    });
    		});
    	},
    	
    	onLoadUser : function(responseObject, ioArgs){
    		dijit.byId("editAnotherUser.username").set("value", responseObject.user.username);
    		dijit.byId("editAnotherUser.login").set("value", responseObject.user.login);
    	},
    	
    	onSubmit : function(){
    		return this.isValid() && dijit.byId("editAnotherUserPassword").get('value') == dijit.byId("editAnotherUserConfirmPassword").get('value');
    	}
    	
    });
});